import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;


public class PowerSet {
	
	
	
	/**Get the power of the set
	 * @param OriginalSet
	 * @return
	 */
	public static <T> Set<Set<T>> getPowerSet(Set<T> OriginalSet){
		
		List<T> list = new ArrayList<T>(OriginalSet);
		
		
		
		Set<Set<T>> result = new HashSet<Set<T>>();
		
		int length = list.size();
		
		for(int i = 0 ; i < (Math.pow(2, length)); i++){
			Set<T> temp = new HashSet<T>();
			for(int j = 0 ; j < length; j++){
				if((i >> j) % 2 == 1){
					temp.add(list.get(j));
				}
			}
			
			result.add(temp);
			
		}
		
		System.out.println(result);
		
		return result;
		
	}
	

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Set<String> test = new HashSet<String>();
		
		test.add("a");
		test.add("b");
		test.add("c");
		
		PowerSet.getPowerSet(test);
		
		

	}

}
